const { defineConfig } = require('@vue/cli-service')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
module.exports = defineConfig({
  publicPath: './',
  configureWebpack: {
    devServer: {
      historyApiFallback: true,
      proxy: {
        '/api': {
          //  /api表示拦截以/api开头的请求路径
          target: 'https://www.kaoyansou.cn/', //跨域的域名
          changeOrigin: true, //是否开启跨域
          pathRewrite: {
            // 重写路径
            '^/api': '' // 把/api变为空字符
          }
        }
      }
    },
    plugins: [
      AutoImport({
        resolvers: [
          ElementPlusResolver({
            exclude: new RegExp(/^(?!.*loading-directive).*$/)
          })
        ]
      }),
      Components({
        resolvers: [ElementPlusResolver()]
      })
    ]
  }
})
